home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
xvisrc.zip
/
PARAM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-28
|
23KB
|
892 lines
/* Copyright (c) 1990,1991,1992 Chris and John Downey */
#ifndef lint
static char *sccsid = "@(#)param.c 2.1 (Chris & John Downey) 7/29/92";
#endif
/***
* program name:
xvi
* function:
PD version of UNIX "vi" editor, with extensions.
* module name:
param.c
* module function:
Code to handle user-settable parameters. This is all pretty much
table-driven. To add a new parameter, put it in the params array,
and add a macro for it in param.h.
The idea of the parameter table is that access to any particular
parameter has to be fast, so it is done with a table lookup. This
unfortunately means that the index of each parameter is recorded
as a macro in param.h, so that file must be changed at the same
time as the table below, and in the same way.
When a parameter is changed, a function is called to do the actual
work; this function is part of the parameter structure. For many
parameters, it's just a simple function that prints "not implemented";
for most others, there are "standard" functions to set bool, numeric
and string parameters, with a certain amount of checking.
No bounds checking is done here; we should really include limits
to numeric parameters in the table. Maybe this will come later.
The data structures will be changed again shortly to enable
buffer- and window-local parameters to be implemented.
One problem with numeric parameters is that they are of type "int";
this obviously places some restrictions on the sort of things they
may be used for, and it may be necessary at some point to change
this type to something like "unsigned long".
* history:
STEVIE - ST Editor for VI Enthusiasts, Version 3.10
Originally by Tim Thompson (twitch!tjt)
Extensive modifications by Tony Andrews (onecom!wldrdg!tony)
Heavily modified by Chris & John Downey
***/
#include "xvi.h"
#define nofunc PFUNCADDR(NULL)
/*
* Default settings for string parameters.
* These are set by the exported function init_params(),
* which must be called before any parameters are accessed.
*/
#define DEF_TAGS "tags,/usr/lib/tags"
#define DEF_PARA "^($|\\.([ILPQ]P|LI|[plib]p))"
#define DEF_SECTIONS "^({|\\.([NS]H|HU|nh|sh))"
#define DEF_SENTENCES "\\<[A-Z]"
/*
* Default setting for roscolour parameter is the same
* as the statuscolour if not specified otherwise.
*/
#ifndef DEF_ROSCOLOUR
#define DEF_ROSCOLOUR DEF_STCOLOUR
#endif
/*
* Default settings for showing control- and meta-characters are
* as for "normal" vi, i.e. "old" xvi without SHOW_META_CHARS set.
*/
#ifndef DEF_CCHARS
# define DEF_CCHARS FALSE
#endif
#ifndef DEF_MCHARS
# define DEF_MCHARS FALSE
#endif
/*
* Internal functions.
*/
static int strtoi P((char **));
static bool_t _do_set P((Xviwin *, char *, bool_t));
static char *parmstring P((Param *, int));
static void enum_usage P((Xviwin*, Param *));
static bool_t not_imp P((Xviwin *, Paramval, bool_t));
static bool_t set_magic P((Xviwin *, Paramval, bool_t));
static bool_t set_rt P((Xviwin *, Paramval, bool_t));
static char *par_show P((void));
/*
* These are the available parameters. The following are non-standard:
*
* autosplit format helpfile jumpscroll preserve
* preservetime regextype vbell edit
* colour statuscolour roscolour systemcolour
*/
Param params[] = {
/* fullname shortname flags value function ... */
{ "ada", "ada", P_BOOL, 0, not_imp, },
{ "adapath", "adapath", P_STRING, 0, not_imp, },
{ "autoindent", "ai", P_BOOL, 0, nofunc, },
{ "autoprint", "ap", P_BOOL, 0, not_imp, },
{ "autosplit", "as", P_NUM, 2, nofunc, },
{ "autowrite", "aw", P_BOOL, 0, not_imp, },
{ "beautify", "bf", P_BOOL, 0, not_imp, },
{ "cchars", "cchars", P_BOOL, DEF_CCHARS, nofunc, },
{ "colour", "co", P_NUM, DEF_COLOUR, nofunc, },
{ "directory", "dir", P_STRING, 0, not_imp, },
{ "edcompatible", "edcompatible", P_BOOL, 0, not_imp, },
{ "edit", "edit", P_BOOL, TRUE, set_edit, },
{ "errorbells", "eb", P_BOOL, 0, nofunc, },
{ "format", "fmt", P_ENUM, 0, set_format,},
{ "hardtabs", "ht", P_NUM, 0, not_imp, },
{ "helpfile", "hf", P_STRING, 0, nofunc, },
{ "ignorecase", "ic", P_BOOL, 0, nofunc, },
{ "jumpscroll", "js", P_ENUM, 0, nofunc, },
{ "lisp", "lisp", P_BOOL, 0, not_imp, },
{ "list", "ls", P_BOOL, 0, nofunc, },
{ "magic", "magic", P_BOOL, TRUE, set_magic, },
{ "mchars", "mchars", P_BOOL, DEF_MCHARS, nofunc, },
{ "mesg", "mesg", P_BOOL, 0, not_imp, },
{ "minrows", "min", P_NUM, 2, nofunc, },
{ "modeline", "modeline", P_BOOL, 0, not_imp, },
{ "number", "nu", P_BOOL, 0, nofunc, },
{ "open", "open", P_BOOL, 0, not_imp, },
{ "optimize", "opt", P_BOOL, 0, not_imp, },
{ "paragraphs", "para", P_STRING, 0, nofunc, },
{ "preserve", "psv", P_ENUM, 0, nofunc, },
{ "preservetime", "psvt", P_NUM, 5, nofunc, },
{ "prompt", "prompt", P_BOOL, 0, not_imp, },
{ "readonly", "ro", P_BOOL, 0, nofunc, },
{ "redraw", "redraw", P_BOOL, 0, not_imp, },
{ "regextype", "rt", P_ENUM, 0, set_rt, },
{ "remap", "remap", P_BOOL, 0, nofunc, },
{ "report", "report", P_NUM, 5, nofunc, },
{ "roscolour", "rst", P_NUM, DEF_ROSCOLOUR, nofunc, },
{ "scroll", "scroll", P_NUM, 0, not_imp, },
{ "sections", "sections", P_STRING, 0, nofunc, },
{ "sentences", "sentences", P_STRING, 0, nofunc, },
{ "shell", "sh", P_STRING, 0, nofunc, },
{ "shiftwidth", "sw", P_NUM, 8, nofunc, },
{ "showmatch", "sm", P_BOOL, 0, nofunc, },
{ "slowopen", "slowopen", P_BOOL, 0, not_imp, },
{ "sourceany", "sourceany", P_BOOL, 0, not_imp, },
{ "statuscolour", "st", P_NUM, DEF_STCOLOUR, nofunc, },
{ "systemcolour", "sy", P_NUM, DEF_SYSCOLOUR, nofunc, },
{ "tabs", "tabs", P_BOOL, TRUE, nofunc, },
{ "tabstop", "ts", P_NUM, 8, nofunc, },
{ "taglength", "tlh", P_NUM, 0, nofunc, },
{ "tags", "tags", P_LIST, 0, nofunc, },
{ "term", "term", P_STRING, 0, not_imp, },
{ "terse", "terse", P_BOOL, 0, not_imp, },
{ "timeout", "timeout", P_NUM, DEF_TIMEOUT, nofunc, },
{ "ttytype", "ttytype", P_STRING, 0, not_imp, },
{ "vbell", "vb", P_BOOL, 0, nofunc, },
{ "warn", "warn", P_BOOL, 0, not_imp, },
{ "window", "window", P_NUM, 0, not_imp, },
{ "wrapmargin", "wm", P_NUM, 0, nofunc, },
{ "wrapscan", "ws", P_BOOL, TRUE, nofunc, },
{ "wri